
package View;

import View.SlidePuzzleGUI;
import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author Simon Marshall - jc209673
 */
public class MoveCounter {
    
    /**
     * This class is meant to be part of SlidePuzzleGUI.java
     */
    
    private int counter = 0;
    private SlidePuzzleGUI UI;
    Timer timer;
    private boolean active = false;
    private boolean paused = false;

    /**
     * 
     * @param GUI - Initializes the MoveCounter in the GUI to increment moves taken by 1 for each valid move that happens on  the game board.
     */
    public MoveCounter(SlidePuzzleGUI GUI) {
        UI = GUI;

        timer = new Timer();
        timer.schedule(new TimerTask() {

            @Override
            public void run() {
                if (paused == false) {
                    ++counter;
                }
                UI.UpdateTimerLabel(counter);
            }
        }, 0, 1000);
    }

    /**
     * Changes the MoveCounter to true after doCount is initialized
     */
    public void doCount() {
        paused = false;
    }
    /**
     * Resets moves taken to 0 when New Game is started
     */
    public void doCounterReset() {
        counter = 0;
        paused = true;
    }
    
}
